Overview
Exit code is called when CLIP is shutting down and provides a means for objects to release any resources that they have.
For more information about the content of a circuit definition, refer to Circuit Definitions.
Examples
Exit
The function Exit() is simply used to tidy up any allocations, or to close any devices opened by the object. The following example shows the exit code for a thread that must close its associated device when the thread exits (generated code is shown in black, additional user code is highligted in red).
Uns Cct1_ControllerThrdElem::Exit()
{
Uns failed = FALSE;
failed |= ! Cct1_ControllerThrdBaseElem::Exit();
// close an open device
if ( this->mDevice.IsOpen() )
this->mDevice.Close();
return ! failed;
}
The following example shows method exit code that releases memory allocated by its workspace object on exit (generated code is shown in black, additional user code is highligted in red):
Uns Cct1_FFTMthdElem::Exit()
{
Uns failed = FALSE;
// free scratchpad
if ( this->Workspace().Data().ScratchPadSize() > 0 )
{
delete this->Workspace().Data().ScratchPad();
this->Workspace().Data().ScratchPadSize() = 0;
}
failed |= ! Cct1_FFTMthdBaseElem::Exit();
return ! failed;
}